package com.cyam.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cyam.domain.Message;
import com.cyam.mapper.MessageMapper;
import com.cyam.service.MessageService;
import com.cyam.util.Pager;
/**
 * 留言 service 实现
 * @author CourageAQ
 *
 */
@Service
@Transactional
public class MessageServiceImpl implements MessageService {
	
	@Resource
	private MessageMapper messageMapper;

	@Override
	public void save(Message t) throws Exception {
		messageMapper.insertObject(t);
	}

	@Override
	public void update(Message t) throws Exception {
		messageMapper.modifyObject(t);
	}

	@Override
	public void remove(int id) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public List<Message> findAll(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message findOne(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Pager findPager(Map<String, Object> map, int page, int size) throws Exception {
		map.put("beginPageCount", size * (page-1));
		map.put("pageSize", size);
		List<Message> list = messageMapper.selectPage(map);
		int count = messageMapper.countObject(map);
		Pager pager = new Pager(size, page, count, list);
		return pager;
	}

	@Override
	public Pager countPager(Map<String, Object> map, int page, int size) throws Exception {
		int count = messageMapper.countObject(map);
		Pager pager = new Pager(size, page, count);
		return pager;
	}

}
